home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed wipes ƒ / Rescue Raiders reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.1 KB  |  107 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Rescue Raiders reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 5
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short RescueRaidersReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  36.  
  37. /* One region in 8 parts.  Each part of the region either starts at a corner
  38.    or in the middle of a side and moves progressively counterclockwise until the
  39.    entire screen is filled. Named after a similar effect in the game Rescue
  40.    Raiders on the Apple ][e (now called Armor Alley™ on the Mac, but it doesn't
  41.    have this effect in it anymore). */
  42.    
  43. pascal short RescueRaidersReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  44. {
  45.     RgnHandle    curregion;
  46.     int            cx,cy,lastx,lasty;
  47.     int            BlockSize, VBlockSize;
  48.     
  49.     cx = theWindowWidth / 2;
  50.     cy = theWindowHeight / 2;
  51.     BlockSize=theWindowWidth/25;
  52.     VBlockSize=theWindowHeight/25;
  53.  
  54.     lastx=cx-BlockSize;
  55.     lasty=cy-VBlockSize;
  56.     curregion=NewRgn();
  57.     do
  58.     {
  59.         StartTiming();
  60.  
  61.         SetEmptyRgn(curregion);
  62.         MoveTo(cx,cy);
  63.         OpenRgn();
  64.             LineTo(lastx,0);
  65.             Line(BlockSize,0);
  66.             LineTo(theWindowWidth-lastx-BlockSize,theWindowHeight);
  67.             Line(BlockSize,0);
  68.             LineTo(cx,cy);
  69.             
  70.             LineTo(cx+lastx,0);
  71.             Line(BlockSize,0);
  72.             LineTo(cx-lastx-BlockSize,theWindowHeight);
  73.             Line(BlockSize,0);
  74.             LineTo(cx,cy);
  75.             
  76.             LineTo(theWindowWidth,lasty);
  77.             Line(0,VBlockSize);
  78.             LineTo(0,theWindowHeight-lasty-VBlockSize);
  79.             Line(0,VBlockSize);
  80.             LineTo(cx,cy);
  81.             
  82.             LineTo(theWindowWidth,cy+lasty);
  83.             Line(0,VBlockSize);
  84.             LineTo(0,cy-lasty-VBlockSize);
  85.             Line(0,VBlockSize);
  86.             LineTo(cx,cy);
  87.         CloseRgn(curregion);
  88.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  89.         
  90.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  91.             &boundsRect, &boundsRect, 0, curregion);
  92.  
  93.         lastx-=BlockSize;
  94.         lasty-=VBlockSize;
  95.  
  96.         TimeCorrection(CorrectTime);
  97.     }
  98.     while (lastx>=0);
  99.     
  100.     CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  101.         &boundsRect, &boundsRect, 0, 0L);   /* in case we missed any bits */
  102.     
  103.     DisposeRgn(curregion);
  104.     
  105.     return 0;
  106. }
  107.